package com.douxg.fastCoding.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.douxg.fastCoding.spring.base.MyBaseServiceImpl;
import com.douxg.fastCoding.web.entity.Dict;
import com.douxg.fastCoding.web.mapper.DictMapper;
import com.douxg.fastCoding.web.service.DictService;
import com.douxg.fastCoding.web.util.DataConverUtil;
import com.douxg.fastCoding.web.vo.ElSelectVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Auther douxg
 * @Date 2021/6/16 18:47
 */
@Service
public class DictServiceImpl extends MyBaseServiceImpl<DictMapper, Dict> implements DictService {
    @Override
    public List<ElSelectVo> listByType(Dict dto) {
        List<Dict> list = list(new QueryWrapper<>(dto));
        List<ElSelectVo> listByEntity = ElSelectVo.createListByEntity(list, Dict.Column.LABEL, Dict.Column.VALUE);
        return listByEntity;
    }

    @Override
    public Map<String, Object> MapByType(Dict dto) {
        List<Dict> list = list(new QueryWrapper<>(dto));
        Map<String, Object> map = DataConverUtil.listToMap(list, Dict.Column.VALUE, Dict.Column.LABEL);
        return map;
    }
}
